class_name LevelConfig extends RefCounted

var id: String
var layers: int
var meta_data: Dictionary
var base_weather: int  # 新增属性

@export_group("布局参数")
@export var horizontal_spacing: float = 140.0
@export var vertical_spacing: float = 90.0

static func load_from_id(level_id: String) -> LevelConfig:
	var config_data = _ConfigManager.get_level_config(level_id)
	assert(config_data.has("base_weather"), "关卡配置缺少 base_weather 字段！")
	var config = LevelConfig.new()
	config.id = level_id
	config.layers = config_data.get("layers", 5)
	config.base_weather = config_data.get("base_weather", 0)  # 从数据源提取
	config.meta_data = config_data
	return config
	
func get_config_meta(key: String) -> Variant:
	return meta_data.get(key, null)
	
static func _create_from_data(data: Dictionary) -> LevelConfig:
	var config = LevelConfig.new()
	config.id = data.get("id", "")
	config.layers = data.get("layers", 5)
	config.weather = data.get("base_weather", "sunny")
	config.enemy_pool = _ConfigManager.get_config_pool(
		_ConfigManager.CONFIG_TYPES.ENEMY, 
		data.get("enemy_pool", "")
	)
	config.photo_pool = _ConfigManager.get_config_pool(
		_ConfigManager.CONFIG_TYPES.PHOTO,
		data.get("photo_pool", "")
	)
	config.equipment_pool = _ConfigManager.get_config_pool(
		_ConfigManager.CONFIG_TYPES.EQUIPMENT,
		data.get("equipment_pool", "")
	)
	return config
